<?php
/**
 * 后台入口文件
 */
require('konakona/konakona.php');
k::run();
k::setEncoding('utf-8');

$action = !empty($_GET['action'])?$_GET['action']:'login';
if($action != 'login') if(!admin::isOTOnline())exit;
template::adminTemplatePath();
template::assign('config',k::$config);
k::import( 'helper.page');
error_reporting(E_ALL ^ E_NOTICE);
$id = @intval($_GET['id']);
$pid = intval($_GET['p']);
//常规参数带入
template::adminTemplatePath();
template::assign('config',k::$config);

switch($action){
    case 'login':
        if(!admin::isOTOnline()){
    		if(isset($_POST['user'])){
    		    if($_POST['user']!='' && $_POST['password']!=''){
					admin::OT_login($_POST);
    		    }else{
    		    template::assign('errmsg','Sorry! Your name and the password is error.');
    			template::display('../admin/ot_login.html');
    		    }
    		}else{
    			template::display('../admin/ot_login.html');
    		}
          }else{
              template::display('../admin/ot_main.html');
          }
    break;
    case 'logout':
        admin::OT_logout();
    break;
	case 'header':
        template::display('../admin/header.html');
    break;
    case 'ot_menu':
        template::display('../admin/ot_menu.html');
    break;
    case 'folding':
        template::display('../admin/folding.html');
    break;
    case 'system':
	template::assign('admin_name',$_SESSION['kona_admin']);
	template::assign('phpVersion',phpversion());
	template::assign('mysqlVersion',mysql_get_server_info());
	$gd_info = gd_info();
	template::assign('gdVersion',$gd_info['GD Version']);
	template::assign('webInfo',$_SERVER['SERVER_SOFTWARE']);
	template::assign('nowTime',date("Y-m-d h:i",time()));
        template::display('../admin/system.html');
    break;
	case 'reviews-list':
                template::assign('reviews_page',page::run($pid,'tour_reviews','ot.php?action=reviews-list&p='));
		template::assign('reviews_list',reviews::reviews_list($pid,false,10));
		template::display('../admin/reviews-list.html');
	break;
	case 'reviews-add':
		if($_POST['reviews_name']!='' && $_POST['reviews_content']!=''){
			reviews::reviews_add($_POST);
		}else{
			template::assign('tour_title',tour::getTitle($id));
			template::assign('id',$id);
			template::display('../admin/reviews-add.html');
		}
	break;
	case 'reviews-details':
		template::assign('id',$id);
		template::assign('reviews_details',reviews::reviews_details($id));
		template::display('../admin/reviews-edit.html');
	break;
	//反馈图片单张删除
	case 'reviews-pic-del':
		reviews::reviews_pic_del($_GET['pic']);
	break;
	//反馈编辑
	case 'reviews-edit':
		reviews::reviews_edit();
	break;
	case 'reviews-del':
		reviews::reviews_del($id);
	break;
	case 'tour-list':
                template::assign('tour_page',page::run($pid,'tour','ot.php?action=guide-list&p='));
		template::assign('tour_list',tour::tour_list($id));
		template::display('../admin/tour-list.html');
	break;
	case 'order-tour-list':
		template::assign('order_list',order::order_list('tour',$pid));
		template::display('../admin/order-tour-list.html');
	break;
	case 'order-cruise-list':
		template::assign('order_list',order::order_list('cruise',$pid));
		template::display('../admin/order-cruise-list.html');
	break;
	case 'order-cruise-cl':
		order::chuli($id,'cruise',$_GET['status'],$_GET['r']);
		template::assign('order_list',order::order_list('cruise',"处理成功."));
		template::assign('order_list',order::order_list('cruise',$pid));
		template::display('../admin/order-cruise-list.html');
	break;
	case 'order-tour-cl':
		print_r($_GET);
	break;
}
